﻿using System;
using System.Diagnostics;
using System.Windows.Forms;

namespace PhiStore
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            string PhiServerName = Application.ProductName;
            Process[] processes = Process.GetProcesses();
            int count = 0;

            for (int i = 0; i < processes.Length && count < 2; i++) //Process p in processes)
            {
                string processName = processes[i].ProcessName;

                //remove ".vshost" (if running through visual studio)
                if (processName.Contains("."))
                    processName = processName.Substring(0, processName.IndexOf("."));

                if (processName.Equals(PhiServerName))
                    count++;
            }
            
            //only one instance of server running for this user
            //settings is stored automatically
            if (count == 1)
                SettingsManager.Instance.StoreSettings = true;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new ServerUI());
        }
    }
}
